home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 June
/
ChipCD 6.02.iso
/
test
/
nav
/
NAV
/
SWPlugin.dll
/
HTML
/
MAIN.JS
< prev
next >
Wrap
Text File
|
2002-05-06
|
19KB
|
570 lines
// main.js
var ButtonState = START_Scan_OR_Rescan; // set to BeginScan
var ScannerNumber = 0; // set to first scanner
var bFromNSW = false;
var IsOBCFinished = true;
var object_coll = 0;
var font_coll = 0;
var images_coll = 0;
var percent_complete = 0;
var Errors_before_another_scan = 0;
var NumberOfScanners = 0;
var bInitDone = false;
// STORE SCANNER NUMBER WHICH HAS ERRORS
var ScannerIndex = 0;
var TotalScanners_With_Errors = 0;
var TotalNumErrors = 0;
var NumFixedErrors = 0;
var Scanner_With_Errors = new Array(MAXIMUM_Scanners);
function ErrorInfo(Message, Color, IsBold) // constructor for an object that holds a scanner's error information
{
this.Message = Message;
this.Color = Color;
this.IsBold = IsBold;
}
var Scanner_With_Errors_Info = new Array(MAXIMUM_Scanners); // holds the information of a scanner with error(s)
var ScannersFixed = 0; // Number of scanners fix was done on (user could've stopped midstream)
/*********************************************************************************/
// LIST OF ALL THE SCANNERS CLSID
var CLSID_Number = new Array(MAXIMUM_Scanners);
CLSID_Number[0] = "{8104DFEA-D444-11d1-94B4-006008A1AC2F}"; /*CLSID_CoSymRS,Win Reg Scan*/
CLSID_Number[1] = "{8104DFE8-D444-11d1-94B4-006008A1AC2F}"; /*CLSID_CoSymMDScan,Program Integrity Scan*/
CLSID_Number[2] = "{3F4B6C82-46CB-11D4-8785-00C04F48B4B5}"; /*CLSID_FreeSpace, Free Space Scan*/
CLSID_Number[3] = "{2E7389A2-41EF-11d4-8785-00C04F48B4B5}"; /*CLSID_NavDefFiles*/
CLSID_Number[4] = "{2E7389A5-41EF-11d4-8785-00C04F48B4B5}"; /*CLSID_NavAutoProtect*/
CLSID_Number[5] = "{2E7389A6-41EF-11d4-8785-00C04F48B4B5}" /*CLSID_NavLastScan*/
CLSID_Number[6] = "{8104DFE4-D444-11d1-94B4-006008A1AC2F}"; /*CLSID_CLnkScan,Shortcut Scan*/
CLSID_Number[7] = "{A2F50A87-82C2-11D2-B8E6-006097C9C6FF}"; /*CLSID_NDDTest,Disk Doctor*/
CLSID_Number[8] = "{FF914707-6E6C-11D2-B8E6-006097C9C6FF}"; /*CLSID_RegTest,Reg Doctor*/
CLSID_Number[9] = "{A2F50A89-82C2-11D2-B8E6-006097C9C6FF}"; /*CLSID_FragTest, Disk Fragmentation Test*/
/*********************************************************************************/
// LIST OF ALL THE IMAGES USED IN THE PAGE
pict = new Array(3);
pict[0] = "reddash.gif";
pict[1] = "scanner_blink.gif"
pict[2] = "scanner_done.gif";
/*********************************************************************************/
// LIST OF ALL THE SCANNERERROR ID USED IN THE PAGE
var ScannerErrors = new Array(MAXIMUM_Scanners);
ScannerErrors[0] = "Scanner0_Error";
ScannerErrors[1] = "Scanner1_Error";
ScannerErrors[2] = "Scanner2_Error";
ScannerErrors[3] = "Scanner3_Error";
ScannerErrors[4] = "Scanner4_Error";
ScannerErrors[5] = "Scanner5_Error";
ScannerErrors[6] = "Scanner6_Error";
ScannerErrors[7] = "Scanner7_Error";
ScannerErrors[8] = "Scanner8_Error";
ScannerErrors[9] = "Scanner9_Error";
/*********************************************************************************/
// LIST OF ALL THE WRAPPERS INTERFACES USED IN THE SCRIPT
var Wrappers = new Array(MAXIMUM_Scanners);
Wrappers[0] = "Wrapper0";
Wrappers[1] = "Wrapper1";
Wrappers[2] = "Wrapper2";
Wrappers[3] = "Wrapper3";
Wrappers[4] = "Wrapper4";
Wrappers[5] = "Wrapper5";
Wrappers[6] = "Wrapper6";
Wrappers[7] = "Wrapper7";
Wrappers[8] = "Wrapper8";
Wrappers[9] = "Wrapper9";
/*********************************************************************************/
// LIST OF ALL THE IMAGES ID USED IN THE PAGE
var Images = new Array(MAXIMUM_Scanners);
Images[0] = "Image0";
Images[1] = "Image1";
Images[2] = "Image2";
Images[3] = "Image3";
Images[4] = "Image4";
Images[5] = "Image5";
Images[6] = "Image6";
Images[7] = "Image7";
Images[8] = "Image8";
Images[9] = "Image9";
/*********************************************************************************/
// LIST OF ALL THE ERRORCOLOR ID USED IN THE PAGE
var ErrorColors = new Array(MAXIMUM_Scanners);
ErrorColors[0] = "ErrorColor0";
ErrorColors[1] = "ErrorColor1";
ErrorColors[2] = "ErrorColor2";
ErrorColors[3] = "ErrorColor3";
ErrorColors[4] = "ErrorColor4";
ErrorColors[5] = "ErrorColor5";
ErrorColors[6] = "ErrorColor6";
ErrorColors[7] = "ErrorColor7";
ErrorColors[8] = "ErrorColor8";
ErrorColors[9] = "ErrorColor9";
/*********************************************************************************/
window.onload = fnInit;
function fnInit()
{
// load the resource document so we can use the resources right away
LoadResourceDoc();
str = window.location.protocol;
if ( str != "" )
{
str.toLowerCase();
offset = str.indexOf("res:");
if (offset == 0 )
bFromNSW = true;
else
bFromNSW = false;
}
// Set the windows status bar
str = parent.GetString("STATUSBAR_MAIN", "", "");
if ( !parent.bFromNSW )
str += parent.GetString("STATUSBAR_ONLINE", "", "");
window.status = str;
object_coll = document.all.tags("OBJECT"); //get collection of all the OBJECT tags
font_coll = scanners_frame.document.body.all.tags("FONT"); //get collection of all the FONT tags
images_coll = scanners_frame.document.body.all.tags("IMG"); //get collection of all the IMG tags
buttons_frame.MultiPurposeButton.style.backgroundImage = "url(button_up.gif)";
bInitDone = true;
}
/*********************************************************************************/
document.onstop = fnStopper;
function fnStopper()
{
if(!IsOBCFinished)
{
if(ButtonState == STOP_Scan)
object_coll(Wrappers[ScannerNumber]).StopScan();
else if(ButtonState == STOP_Fix)
{
// stop scanning and fixing (in case we are in silent scan)
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).StopFix();
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).StopScan();
}
// The scanner is stopped before the Stop functions return.
// This is important because there is no way to determine when
// the scanner has stopped if the page is being unloaded.
Wrapper0.SetOBCIdle();
IsOBCFinished = true;
}
}
window.onunload = fnUnInit;
function fnUnInit()
{
if(!bInitDone)
fnInit();
if(!IsOBCFinished)
{
if(ButtonState == STOP_Scan)
object_coll(Wrappers[ScannerNumber]).StopScan();
else if(ButtonState == STOP_Fix)
{
// stop scanning and fixing (in case we are in silent scan)
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).StopFix();
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).StopScan();
}
// The scanner is stopped before the Stop functions return.
// This is important because there is no way to determine when
// the scanner has stopped if the page is being unloaded.
Wrapper0.SetOBCIdle();
IsOBCFinished = true;
}
scanners_frame.document.all.scanners_list.style.display = 'none';
scanners_frame.document.all.welcome.style.display = 'block';
if(CLSID_Number != null)
delete CLSID_Number;
if(pict != null)
delete pict;
if(ScannerErrors != null)
delete ScannerErrors;
if(Wrappers != null)
delete Wrappers;
if(Images != null)
delete Images;
if(ErrorColors != null)
delete ErrorColors;
if(Scanner_With_Errors != null)
delete Scanners_With_Errrors;
if(Scanner_With_Errors_Info != null)
delete Scanners_With_Errrors_Info;
}
/*********************************************************************************/
// THIS FUNCTION IS USED WHEN SCANNER IS TO BE STARTED
function Run_Scanner()
{
var InitError;
InitError = object_coll(Wrappers[ScannerNumber]).Initialize(CLSID_Number[ScannerNumber]);
if (InitError == 0)
{
// wrapper initialized without errors, proceed with scanning
object_coll(Wrappers[ScannerNumber]).StartScan();
scanners_frame.Update_Image(ScannerNumber,1);
}
else if(InitError == 1)
{
// wrapper could not initialize (the scanner may not be installed)
// update UI appropriately and move to next scanner
OnScanDone(false);
}
}
/*********************************************************************************/
// ONCE ERRORS ARE FOUND AFTER SCANNER IS DONE, THIS FUNCTION IS USED TO FIX THE ERROR
function Fix_Errors( )
{
buttons_frame.scan_complete_message.innerText = NumFixedErrors + GetString("OF", "", "") + TotalNumErrors + GetString("ERRORS_ARE_FIXED", "", "");
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).Fix();
MessageString = parent.GetString("PLEASE_WAIT", "", "");
scanners_frame.Update_Error(Scanner_With_Errors[ScannerIndex],MessageString,"Red",false);
scanners_frame.Update_Image(Scanner_With_Errors[ScannerIndex],1);
}
/*********************************************************************************/
function OnScanDone(bSuccessful)
{
scanners_frame.Update_UI(bSuccessful);
buttons_frame.document.body.all.scan_complete_message.innerText = ScannerNumber + 1 + GetString("OF", "", "") + NumberOfScanners + GetString("SCAN_COMPLETE_MESSAGE", "", "");
ScannerNumber++;
buttons_frame.Update_ProgressBar(START_Scan_OR_Rescan);
if(ScannerNumber < NumberOfScanners)
Run_Scanner();
else
{
IsOBCFinished = true;
buttons_frame.Set_Button_Text(true);
StopScanUpdateUI();
}
}
/*********************************************************************************/
function GetDescription( )
{
var Message1 = parent.GetString("UNABLE_TO_FIX_ERRORS", "", "");
switch(Scanner_With_Errors[ScannerIndex])
{
case REGISTRY_Doctor:
case WIN_Reg_Scan:
case PROGRAM_Integrity_Scan:
case SHORTCUT_Scan:
Message1 = parent.GetString("NORTON_WIN_DOCTOR", "", "");
break;
case DISK_Doctor:
Message1 = parent.GetString("NORTON_DISK_DOCTOR", "", "");
break;
case FREE_Space_Scan:
Message1 = parent.GetString("CLEANSWEEP", "", "");
break;
case DISK_Fragmentation_Scan:
Message1 = parent.GetString("SPEED_DISK", "", "");
break;
case VIRUS_Definition_Files_Checker:
Message1 = parent.GetString("LIVE_UPDATE", "", "");
break;
case NAV_Autoprotect_Checker:
Message1 = parent.GetString("AUTO_PROTECT", "", "");
break;
case NAV_Last_Scan_Checker:
Message1 = parent.GetString("SCAN_FOR_VIRUSES", "", "");
break;
}
return Message1;
}
function GetAppendTextToLink( )
{
var Message2;
switch(Scanner_With_Errors[ScannerIndex])
{
case WIN_Reg_Scan:
case PROGRAM_Integrity_Scan:
case REGISTRY_Doctor:
case SHORTCUT_Scan:
case VIRUS_Definition_Files_Checker:
case DISK_Doctor:
case DISK_Fragmentation_Scan:
Message2 = parent.GetString("RUN", "", "");
break;
case NAV_Last_Scan_Checker:
Message2 = parent.GetString("USE_NORTON_ANTIVIRUS_TO", "", "");
break;
}
return Message2;
}
function GetNoPointProductMsg(iScannerIndex)
{
var Message;
switch(iScannerIndex)
{
case WIN_Reg_Scan:
case PROGRAM_Integrity_Scan:
case REGISTRY_Doctor:
case SHORTCUT_Scan:
case DISK_Doctor:
case DISK_Fragmentation_Scan:
Message = GetString("INSTALL_POINTPRODUCT_NU", "", "");
break;
case FREE_Space_Scan:
Message = GetString("INSTALL_POINTPRODUCT_NCS", "", "");
break;
case VIRUS_Definition_Files_Checker:
case NAV_Autoprotect_Checker:
case NAV_Last_Scan_Checker:
Message = GetString("INSTALL_POINTPRODUCT_NAV", "", "");
break;
}
return Message;
}
function GetProductInstalledError(iScannerIndex)
{
return object_coll(Wrappers[iScannerIndex]).CheckProductInstalled(CLSID_Number[iScannerIndex]);
}
/*********************************************************************************/
function OnSilentScan()
{
var MessageString; // string to display when all fixing is over (so links don't appear right away)
var tmpMessageString; // string to display right now
var NewDescription = "";
var Color="Green";
var NumErrorsFoundAgain = object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).numErrors;
if(NumErrorsFoundAgain <= 0)
{
NumFixedErrors += Errors_before_another_scan;
MessageString = parent.GetString("ERRORS_FIX_MESSAGE", "", "");
tmpMessageString = MessageString;
}
else
{
if(NumErrorsFoundAgain < Errors_before_another_scan)
NumFixedErrors += Errors_before_another_scan - NumErrorsFoundAgain;
var Message1 = GetDescription();
var Message2 = GetAppendTextToLink();
var ProductInstalledError = 0;
ProductInstalledError = GetProductInstalledError(Scanner_With_Errors[ScannerIndex]);
if(ProductInstalledError)
{
// update scanner description to tell user to install point product
NewDescription = GetNoPointProductMsg(Scanner_With_Errors[ScannerIndex]);
}
if((Scanner_With_Errors[ScannerIndex] != NAV_Autoprotect_Checker)&&(Scanner_With_Errors[ScannerIndex] != FREE_Space_Scan))
{
if(ProductInstalledError)
{
MessageString = Message2 + Message1;
tmpMessageString = MessageString;
}
else
{
MessageString = Message2 +'<U STYLE="cursor:hand;font-weight: bold" OnClick="LaunchPointProduct('+Scanner_With_Errors[ScannerIndex]+',this)">'+ Message1 +'</U>';
tmpMessageString = Message2 + Message1;
}
}
else
{
MessageString = Message1;
tmpMessageString = MessageString;
}
Color = "Red";
}
buttons_frame.scan_complete_message.innerText = NumFixedErrors + parent.GetString("OF", "", "") + TotalNumErrors + parent.GetString("ERRORS_ARE_FIXED", "", "");
// store the real error string away to update later, show the temporary string now
scanners_frame.Update_Error(Scanner_With_Errors[ScannerIndex],tmpMessageString,Color,false);
Scanner_With_Errors_Info[ScannerIndex] = new ErrorInfo(MessageString, Color, false);
scanners_frame.Update_Image(Scanner_With_Errors[ScannerIndex],2);
if (NewDescription != "")
scanners_frame.Update_Description(Scanner_With_Errors[ScannerIndex], NewDescription);
buttons_frame.Update_ProgressBar(START_Fix);
ScannersFixed++;
ScannerIndex++;
if(ScannerIndex < TotalScanners_With_Errors)
Fix_Errors( );
else
{
TotalScanners_With_Errors = 0;
ScannerIndex = 0;
IsOBCFinished = true;
buttons_frame.Set_Button_Text(false);
StopScanUpdateUI();
UpdateErrorMessages(); // show the error messages, with the links if appropriate
}
}
/*********************************************************************************/
function UpdateErrorMessages()
{
var i;
var MessageString;
var Color;
var IsBold;
for (i=0; i < ScannersFixed; i++)
{
MessageString = Scanner_With_Errors_Info[i].Message;
Color = Scanner_With_Errors_Info[i].Color;
IsBold = Scanner_With_Errors_Info[i].IsBold;
scanners_frame.Update_Error(Scanner_With_Errors[i], MessageString, Color, IsBold);
}
}
/*********************************************************************************/
function OnErrorsFixed()
{
var ScannerTableRowID = "ScannerTableRow" + ScannerIndex;
scanners_frame.document.body.all.item(ScannerTableRowID).scrollIntoView(true);
Errors_before_another_scan = object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).numErrors;
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).Initialize(CLSID_Number[Scanner_With_Errors[ScannerIndex]]);
object_coll(Wrappers[Scanner_With_Errors[ScannerIndex]]).StartScan();
}
/*********************************************************************************/
// THIS IS CALLBACK FUNCTION BY THE INTERFACE TO COMMUNICATE BETWEEN INTERFACE AND
// JAVASCRIPT
function ObjectSink(msg, param1, param2)
{
switch(msg)
{
case SM_ScanDone:
if(ButtonState != STOP_Fix)
{
if(ButtonState == STOP_Scan)
OnScanDone(true);
else
buttons_frame.EnableButton();
}
else
OnSilentScan();
break;
case SM_OneProblemFixed:
if(param1 <= 0)
OnErrorsFixed();
break;
case SM_Abort:
buttons_frame.EnableButton();
break;
}
}
/*********************************************************************/
function Set_Defaults()
{
scanners_frame.Set_Defaults();
}
/*********************************************************************/
function Update_Image(Index,Gif_Number )
{
scanners_frame.Update_Image(Index,Gif_Number);
}
/*********************************************************************/
function Update_Error(Index,ErrorString,ColorName,IsBold)
{
scanners_frame.Update_Error(Index,ErrorString,ColorName,IsBold);
}
/*********************************************************************/
function Update_ProgressBar(Status)
{
buttons_frame.Update_ProgressBar(Status);
}
/*********************************************************************/
// Inform user that OBC can't run while a point product is running
function ShowError_PointProductRunning()
{
// point product is running alone, so we can't start scanning
// or fixing, display the message and stop
var CloseAppMessage = parent.GetString("CLOSE_POINT_PRODUCT_MESSAGE", "", "");
alert(CloseAppMessage);
buttons_frame.Set_Button_Text(true);
}
/*********************************************************************/
function StartScanUpdateUI()
{
var SetOBCBusyError;
SetOBCBusyError = Wrapper0.SetOBCBusy();
if (SetOBCBusyError == 0)
{
scanners_frame.SetBusy(true);
return true;
}
else
{
// means point product is running alone, so we can't start scanning
// display the message and force the user to rescan
ShowError_PointProductRunning();
buttons_frame.document.body.all.scan_complete_message.innerText = ScannerNumber + GetString("OF", "", "") + NumberOfScanners + GetString("SCAN_COMPLETE_MESSAGE", "", "");
return false;
}
}
/*********************************************************************/
function StopScanUpdateUI()
{
Wrapper0.SetOBCIdle();
scanners_frame.SetBusy(false);
}
/*********************************************************************/
function StartFixUpdateUI()
{
var SetOBCBusyError;
SetOBCBusyError = Wrapper0.SetOBCBusy();
if (SetOBCBusyError == 0)
{
scanners_frame.SetBusy(true);
return true;
}
else
{
// means point product is running alone, so we can't start fixing
// display the message and force the user to rescan
ShowError_PointProductRunning();
buttons_frame.scan_complete_message.innerText = NumFixedErrors + GetString("OF", "", "") + TotalNumErrors + GetString("ERRORS_ARE_FIXED", "", "");
return false;
}
}
/*********************************************************************/
function StopFixUpdateUI()
{
Wrapper0.SetOBCIdle();
scanners_frame.SetBusy(false);
}
function LoadRes()
{
// load the resource document so we can use the resources right away
LoadResourceDoc();
}